package droid.insane.GUI;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import droid.insane.database.DBHandler;
import droid.insane.logic.R;

/**
 * @author Sandamal
 * Shows that splash screen and initiates the program
 */

public class LKFinance extends Activity {

	private static final int STOPSPLASH = 0;

	// time in milliseconds
	private static final long SPLASHTIME = 500;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		Message msg = new Message();
		msg.what = STOPSPLASH;
		splashHandler.sendMessageDelayed(msg, SPLASHTIME);
		initialize();
	}

	/**
	 * Initialize the DBHandler
	 */
	private void initialize() {
		DBHandler.getDBHandler(this);
	}

	// handler for splash screen
	private Handler splashHandler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case STOPSPLASH:
				// start the next activity

				Intent tabWindowIntent = new Intent(LKFinance.this,
						MainWindow.class);
				startActivity(tabWindowIntent);
				break;
			}
			super.handleMessage(msg);
		}
	};

	/*
	 * stops returning to the splash screen
	 */
	@Override
	protected void onPause() {
		super.onPause();
		finish();
	}
}
